package com.relytosoft.mizar.media.display.services.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.relytosoft.mizar.media.display.api.entity.ViewDetail;
import com.relytosoft.mizar.media.display.api.pojo.dto.ChannelRtspStreamDto;
import com.relytosoft.mizar.media.display.services.mapper.ViewDetailMapper;
import com.relytosoft.mizar.media.display.services.service.ViewDetailService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 视图明细业务实现类
 *
 * @author hj
 * @version 1.0
 * @date 2022/4/24 9:44
 * @ClassName ViewDetailServiceImpl
 */
@Service
public class ViewDetailServiceImpl extends ServiceImpl<ViewDetailMapper, ViewDetail> implements ViewDetailService {
    @Resource
    private ViewDetailMapper viewDetailMapper;
    /**
     * 通过视图id删除视图明细
     *
     * @param viewIds
     * @return boolean
     * @author jgg
     * @date 2022/4/24 11:09
     */
    @Override
    public boolean deleteByViewIds(List<Integer> viewIds) {
        LambdaQueryWrapper<ViewDetail> wrapper = Wrappers.lambdaQuery();
        wrapper.in(ViewDetail::getFormId , viewIds);
        return remove(wrapper);
    }

    /**
     * 通过视图id查询视图明细
     *
     * @param id
     * @return java.util.List<com.relytosoft.mizar.media.display.api.entity.ViewDetail>
     * @author jgg
     * @date 2022/4/24 11:17
     */
    @Override
    public List<ViewDetail> selectListByViewId(List<Integer> id) {
        LambdaQueryWrapper<ViewDetail> wrapper = Wrappers.lambdaQuery();
        wrapper.in(ViewDetail::getFormId,id)
                .orderByAsc(ViewDetail::getSort);
        return list(wrapper);
    }

    /**
     * 查询对应的rtsp流地址
     *
     * @param id
     * @return java.util.List<com.relytosoft.mizar.media.display.api.pojo.dto.ChannelRtspStreamDto>
     * @author jgg
     * @date 2022/4/24 17:18
     */
    @Override
    public List<ChannelRtspStreamDto> selectRtspListByViewId(Integer id) {
        return viewDetailMapper.selectRtspListByViewId(id);
    }
}
